package com.wgy.blog.controller;

import com.github.pagehelper.PageInfo;
import com.wgy.blog.common.Result;
import com.wgy.blog.pojo.SortNav;
import com.wgy.blog.service.SortNavService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:Iny
 * @Data：2021/11/15 9:33
 */
@RestController
@RequestMapping("sort")
public class SortNavController {

    @Resource
    private SortNavService sortNavService;

    @GetMapping("findAll")
    public Result findAll(PageInfo pageInfo){
        Result<List<SortNav>> result = sortNavService.findAll(pageInfo);
        return result;
    }

    @PutMapping("update")
    public Result update(@RequestBody SortNav sortNav){
        Result result = sortNavService.update(sortNav);
        return result;
    }

    @PostMapping("add")
    public Result add(@RequestBody SortNav sortNav){
        Result result = sortNavService.add(sortNav);
        return result;
    }


    @PutMapping("updateIsShow")
    public Result updateIsShow(@RequestBody SortNav sortNav){
        Result result = sortNavService.updateIsShow(sortNav.getSortId());
        return result;
    }

    @DeleteMapping("delete")
    public Result deleteSortNav(@RequestBody SortNav sortNav){
        Result result = sortNavService.deleteSortNav(sortNav.getSortId());
        return result;
    }

    @GetMapping("findByIsShow")
    public Result findByIsShow(){
        Result result = sortNavService.findByIsShow();
        return result;
    }

}
